package com.mooco.dongba.common.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * 分页实体类
 * @param <T>
 */
@Data
@NoArgsConstructor
public class PageObject<T> implements Serializable {
    private static final long serialVersionUID = 2155306289213821062L;

    private Integer rowCount;// 总记录数

    private Integer pageSize;// 页面大小：每页最多显示的记录数

    private Integer pageCount;// 总页数

    private Integer pageCurrent;// 当前页码值

    private List<T> records;// 当前页记录数

    public PageObject(Integer rowCount, Integer pageSize, Integer pageCurrent, List<T> records) {
        this.rowCount = rowCount;
        this.pageSize = pageSize;
        this.pageCount = rowCount / pageSize;
        if (rowCount % pageSize != 0) this.pageCount++;
        this.pageCurrent = pageCurrent;
        this.records = records;
    }
}
